package com.douziit.meilianoa.base.redis;


import com.douziit.meilianoa.base.utils.StrEncryptUtil;
import com.douziit.meilianoa.base.utils.StrUtil;
import com.douziit.meilianoa.base.utils.TokenUtil;

/**
 * @author MrShun
 * @version 1.0
 * @Date 2017/11/13
 */
public class UserTokenBean {

    /**
     * 用户ID
     */
    private Integer uid;


    /**
     * 位随机串
     **/
    private String nonceStr;


    public UserTokenBean(Integer uid) {
        this.uid = uid;
        this.nonceStr = StrUtil.randomUUID();
    }

    public Integer getUid() {
        return uid;
    }

    public void setUid(Integer uid) {
        this.uid = uid;
    }


    public String getNonceStr() {
        return nonceStr;
    }

    public void setNonceStr(String nonceStr) {
        this.nonceStr = nonceStr;
    }

    public String getMD5Str() {
        return StrEncryptUtil.md5(uid + "_" + "_" + nonceStr);
    }

    public static void main(String[] args) {
        UserTokenBean b = new UserTokenBean(7);
        System.out.println(b.getMD5Str());   //

        System.out.println(TokenUtil.generator("91c1f30bdbe137e442c402b72d7ae997"));

        System.out.println(TokenUtil.getKey(RedisConstant.APP_USER_TOKEN_REDIS_PREFIX, "NWM2YzQwMWFlOTU2MjZhMmI1MTBhZTU1MjlhMzg4NTViYTZmNGY4Mw=="));

    }
}
